﻿/*
* Sunbox DataView
* Tool for customizing layout in SharePoint
*
* Examples and documentation at: http://sunbox.codeplex.com
* 
* Copyright (c) 2011 - 2012 SKB KONTUR
* Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
* 
* Version: 1.5.8 (06/06/2012)
* Requires: jQuery v1.3+ (for options), Fancybox 1.3.4 (for options), CodeMirror (for options)
*
* LGPL license:
*   http://www.gnu.org/licenses/lgpl.html
*/

var sunboxDataViewScriptIncluded = true; SunboxSourceStateMachine = (function () { function f() { this.init() } f.prototype.init = function () { this.sources = []; this.events = [] }; f.prototype.getSource = function (a) { for (var b = 0; b < this.sources.length; b++) { if (this.sources[b].uid == a) return this.sources[b] } return null }; f.prototype.sourceLoadingStart = function (a) { this.setSourceLoading(a, true) }; f.prototype.sourceLoadingEnd = function (a, b, c) { this.setSourceLoading(a, false); var d = { items: b, options: c }; this.notifyEvent("sourceLoaded", a, d) }; f.prototype.onSourceLoaded = function (a, b) { this.events.push({ name: "sourceLoaded", uid: a, callback: b }) }; f.prototype.isLoading = function (a) { var b = this.getSource(a); if (b == null) return false; return b.loading }; f.prototype.setSourceLoading = function (a, b) { var c = this.getSource(a); if (c == null) { var d = { loading: b, uid: a }; this.sources.push(d) } else { c.loading = b } }; f.prototype.notifyEvent = function (a, b, c) { for (var d = 0; d < this.events.length; d++) { if (this.events[d].name == a && this.events[d].uid == b) this.events[d].callback(c) } }; return f })(); SunboxXmlSerializer = (function () { function q() { this.doc = this.createDocument("", "response", null) } q.prototype.serializeDataSourceToNode = function (a, b) { var c = this.doc.createElement(this.formatSourceTitle(a.Title)); var d = this.doc.createElement("Rows"); c.appendChild(d); if (b == null) return c; var f = this.getRequiredFieldsFromDataSource(a); for (var m = 0; m < b.length; m++) { var n = this.doc.createElement("Row"); this.appendObjectToXml(b[m], f, n); d.appendChild(n) } return c }; q.prototype.getRequiredFieldsFromDataSource = function (a) { if (a.ViewFields.length == 0) return []; var b = []; var c = this.convertStringToXml(a.ViewFields).getElementsByTagName("FieldRef"); for (var d = 0; d < c.length; d++) { var f = c[d].getAttribute("Name"); if (f == null) continue; b.push(f) } return b }; q.prototype.appendObjectToXml = function (a, b, c) { var d = c.ownerDocument; for (var f in a) { if (f.length == 0) continue; if (b.length > 0 && this.inArray(f, b) < 0) continue; var m = a[f]; var n = new SPFieldLookupCollection(m); var p = d.createElement(f); if (f.toLowerCase() == "fileref") { if (n.length > 0) { var t = d.createElement("Name"); t.appendChild(d.createTextNode(n[0].LookupValue)); var s = d.createElement("EncodedName"); s.appendChild(d.createTextNode(this.urlEncode(n[0].LookupValue))); var u = this.getPathExtention(n[0].LookupValue); var r = d.createElement("Suffix"); r.appendChild(d.createTextNode(u == undefined ? "" : u)); p.appendChild(t); p.appendChild(s); p.appendChild(r) } else { p.appendChild(d.createTextNode(m)) } } else { if (n.length > 0) { for (var x = 0; x < n.length; x++) { var y = d.createElement("Value"); var A = d.createElement("LookupId"); A.appendChild(d.createTextNode(n[x].LookupId)); var z = d.createElement("LookupValue"); z.appendChild(d.createTextNode(this.htmlEncode(n[x].LookupValue))); y.appendChild(A); y.appendChild(z); p.appendChild(y) } } else { p.appendChild(d.createTextNode(m)) } } c.appendChild(p) } return c }; q.prototype.inArray = function (a, b, c) { var d; var f = Array.prototype.indexOf; if (b) { if (f) { return f.call(b, a, c) } d = b.length; c = c ? c < 0 ? Math.max(0, d + c) : c : 0; for (; c < d; c++) { if (c in b && b[c] === a) { return c } } } return -1 }; q.prototype.createDocument = function (a, b, c) { var d = null; if (window.ActiveXObject) { d = new ActiveXObject("Microsoft.XMLDOM"); d.async = false; d.appendChild(d.createElement(b)) } else if (document.implementation && document.implementation.createDocument) d = document.implementation.createDocument(a, b, c); return d }; q.prototype.convertStringToXml = function (a) { var b; if (window.ActiveXObject) { b = new ActiveXObject('Microsoft.XMLDOM'); b.loadXML(a) } else { var c = new DOMParser(); b = c.parseFromString(a, 'text/xml') } return b }; q.prototype.parseHTML = function (a) { var b = document.createElement("div"); b.innerHTML = a; return b }; q.prototype.convertXmlToString = function (a) { if (typeof a == "string") return a; if (window.ActiveXObject) { return a.xml } else { return (new XMLSerializer()).serializeToString(a) } }; q.prototype.formatSourceTitle = function (a) { var b = a.toString().replace(" ", "_"); return b }; q.prototype.urlEncode = function (a) { return encodeURI(a) }; q.prototype.htmlEncode = function (a) { var b = document.createElement('div'); var c = document.createTextNode(a); b.appendChild(c); return b.innerHTML }; q.prototype.getPathExtention = function (a) { return (/[.]/.exec(a)) ? /[^.]+$/.exec(a) : undefined }; return q })(); window.__sunboxXml = new SunboxXmlSerializer(); SunboxSpDataManager = (function () { function s() { this.init() } s.prototype.init = function () { }; s.prototype.sourcesStateMachine = new SunboxSourceStateMachine(); s.prototype.loadDataSource = function (c, d, f, m, n) { var p = "<QueryOptions>"; if (c.RecursiveScope) p += "<ViewAttributes Scope=\"Recursive\" />"; if (d.length > 0) p += "<Paging ListItemCollectionPositionNext=\"" + __sunboxXml.htmlEncode(d) + "\" />"; p += "</QueryOptions>"; var t = this; c.loading = true; if (this.sourcesStateMachine.isLoading(f)) { this.sourcesStateMachine.onSourceLoaded(f, function (a) { c.loading = false; m(c, a.items, a.options) }) } else { this.sourcesStateMachine.sourceLoadingStart(f); SPData.getSPListItems(c.ListId, c.ViewId, c.Query, c.ViewFields, c.RowLimit == 0 ? null : c.RowLimit, p, function (a, b) { c.loading = false; t.sourcesStateMachine.sourceLoadingEnd(f, a, b); m(c, a, b) }, function (a) { c.loading = false; t.sourcesStateMachine.sourceLoadingEnd(f, null, null); n(a) }, c.WebUrl) } }; return s })(); SunboxLocalDataManager = (function () { function p() { this.init() } p.prototype.init = function () { this.cacheKeyIndentifier = "__sunboxdtv_"; this.dateDiff = { inMinutes: function (a, b) { var c = b.getTime(); var d = a.getTime(); return parseInt((c - d) / (60 * 1000)) }, inHours: function (a, b) { var c = b.getTime(); var d = a.getTime(); return parseInt((c - d) / (3600 * 1000)) }, inDays: function (a, b) { var c = b.getTime(); var d = a.getTime(); return parseInt((c - d) / (24 * 3600 * 1000)) }, inWeeks: function (a, b) { var c = b.getTime(); var d = a.getTime(); return parseInt((c - d) / (24 * 3600 * 1000 * 7)) } } }; p.prototype.loadDataSource = function (a, b, c) { var d = this.getCacheObject(); if (d == null || a.Modified == null) return null; var f = typeof b == "undefined" || b == null || b.length == 0 ? "" : MD5(b); var m = d.getItem(this.cacheKeyIndentifier + c + "_" + f + "_modified"); if (m == null) return null; if (m != a.Modified) { this.removeDataSource(c); return null } var n = {}; n.data = d.getItem(this.cacheKeyIndentifier + c + "_" + f + "_data"); n.pagedData = d.getItem(this.cacheKeyIndentifier + c + "_" + f + "_pageddata"); d.setItem(this.cacheKeyIndentifier + c + "_lastused", (new Date()).toString()); return n }; p.prototype.saveDataSource = function (a, b, c) { var d = this.getCacheObject(); if (d == null || a.Modified == null) return; var f = typeof b == "undefined" || b == null || b.length == 0 ? "" : MD5(b); var m = __sunboxXml.convertXmlToString(a.rootElement); try { d.setItem(this.cacheKeyIndentifier + c + "_" + f + "_data", m); if (a.pagedData != null && a.pagedData.length > 0) d.setItem(this.cacheKeyIndentifier + c + "_" + f + "_pageddata", a.pagedData); d.setItem(this.cacheKeyIndentifier + c + "_" + f + "_modified", a.Modified); d.setItem(this.cacheKeyIndentifier + c + "_lastused", (new Date()).toString()) } catch (e) { if (e == window.QUOTA_EXCEEDED_ERR) { this.clearCache() } } }; p.prototype.getCacheObject = function () { if (typeof (localStorage) == "undefined") { return null } else { return localStorage } }; p.prototype.isSupportedStorage = function () { return this.getCacheObject() != null }; p.prototype.removeDataSource = function (a) { var b = this.getCacheObject(); if (b == null) return; var c = this.cacheKeyIndentifier + a; for (var d in b) { if (d.startsWith(c)) { b.removeItem(d) } } }; p.prototype.getAllDataSourceslUids = function () { var a = this.getCacheObject(); if (a == null) return []; var b = []; for (var c in a) { if (c.startsWith(this.cacheKeyIndentifier) && c.endsWith("_lastused")) { b.push(c.replace(this.cacheKeyIndentifier, "").replace("_lastused", "")) } } return b }; p.prototype.recycleOldDataSources = function () { if (!this.isSupportedStorage()) return; var a = this.getCacheObject(); var b = this.getAllDataSourceslUids(); for (var c = 0; c < b.length; c++) { var d = a.getItem(this.cacheKeyIndentifier + b[c] + "_lastused"); if (d == null) continue; var f = new Date(d); if (this.dateDiff.inHours(f, new Date()) > 48) { this.removeDataSource(b[c]) } } }; p.prototype.clearCache = function () { var a = this.getCacheObject(); if (a == null) return; a.clear() }; return p })(); SunboxCommonDataManager = (function () { function s() { this.init() } s.prototype.sunboxSpDataManager = new SunboxSpDataManager(); s.prototype.sunboxLocalDataManager = new SunboxLocalDataManager(); s.prototype.init = function () { if (typeof (window.__sunboxdtvrecylecacheinit) == "undefined") { window.__sunboxdtvrecylecacheinit = true; var a = this; setTimeout(function () { a.sunboxLocalDataManager.recycleOldDataSources.call(a.sunboxLocalDataManager) }, 2000) } }; s.prototype.loadDataSource = function (b, c, d, f) { var m, n; var p = this; if (this.sunboxLocalDataManager.isSupportedStorage()) { if (b.CacheOnClient) { n = this.calculateDataSourceUid(b, ""); var t = this.sunboxLocalDataManager.loadDataSource(b, c, n); if (t != null) { b.pagedData = t.pagedData; b.rootElement = __sunboxXml.convertStringToXml(t.data).firstChild; d(b); return } } m = this.calculateDataSourceUid(b, c); this.loadDataSourceFromSp(b, c, m, function (a) { if (a.CacheOnClient) { p.sunboxLocalDataManager.saveDataSource(a, c, n) } d(a) }, f) } else { m = this.calculateDataSourceUid(b, c); this.loadDataSourceFromSp(b, c, m, function (a) { if (a.CacheOnClient && p.sunboxLocalDataManager.isSupportedStorage()) { n = this.calculateDataSourceUid(a, ""); p.sunboxLocalDataManager.saveDataSource(b, c, n) } d(a) }, f) } }; s.prototype.loadDataSourceFromSp = function (d, f, m, n, p) { this.sunboxSpDataManager.loadDataSource(d, f, m, function (a, b, c) { if (c == null) c = {}; a.pagedData = c.ListItemCollectionPositionNext; a.rootElement = __sunboxXml.serializeDataSourceToNode(a, b); n(a) }, function (a) { d.items = null; d.rootElement = __sunboxXml.serializeDataSourceToNode(d, null); p(a) }) }; s.prototype.calculateDataSourceUid = function (a, b) { var c = "<QueryOptions>"; if (a.RecursiveScope) c += "<ViewAttributes Scope=\"Recursive\" />"; if (b.length > 0) c += "<Paging ListItemCollectionPositionNext=\"" + __sunboxXml.htmlEncode(b) + "\" />"; c += "</QueryOptions>"; return this.getDataSourceUid(a, c) }; s.prototype.getDataSourceUid = function (a, b) { var c = ""; if (typeof (window._spPageContextInfo) != 'undefined') { c = window._spPageContextInfo.userId.toString() } var d = c + a.ListId + a.ViewId + a.Query + a.ViewFields + +a.RowLimit + b; return MD5(d) }; return s })(); SunboxDataView = (function () { function o(a, b) { this.options = b; if (typeof this.options.parameters == "undefined") this.options.parameters = []; this.container = a; this.events = []; this.errors = []; this.windowContainer = document.getElementById('s4-workspace'); this.scrollingBeforePixels = 150; this.init() } o.prototype.dataManager = new SunboxCommonDataManager(); o.prototype.init = function () { if (typeof this.options.initFunction == 'function') { this.options.initFunction.call(this) } if (typeof o.lang[this.options.lang] != 'undefined') this.locale = o.lang[this.options.lang]; else this.locale = o.lang.en; this.showLoader(); this.initQueryStrings(); if (typeof this.windowContainer != "undefined" && this.getSourcesByPagerStyle(3).length > 0) { var a = this; this.windowContainer.onscroll = function () { a.checkPagerLoadOnScroll.call(a) } } if (this.options.datasources.length == 0) { this.container.appendChild(document.createTextNode(this.locale.dataViewNoDataSourceMessage)) } else { this.loadDataSources(this.options.datasources, function () { this.hideLoader(); this.renderDataSources(this.options.datasources); this.drawPagers(); this.notifyAfterRender(); this.checkPagerLoadOnScroll() }) } }; o.prototype.tabClicked = function (a) { var b = this.getTarget(a); if (typeof b == "undefined") return; var c = b.nextSibling; while (c != undefined && c.nodeType == 3) { c = c.nextSibling } var d = c.style.display; if (d == "block") c.style.display = "none"; else c.style.display = "block" }; o.prototype.htmlDecode = function (a) { var b = document.createElement('div'); b.innerHTML = a; return b.firstChild.nodeValue }; o.prototype.renderXml = function (b) { var c = __sunboxXml.convertStringToXml(this.htmlDecode(this.options.xsltemplate.Xsl)); if (this.options.debug) { var d = c.getElementsByTagName("parsererror"); if (d != null && d.length > 0) { this.registerError("", this.getHtmlOfXmlElement(d[0]), "Error while parsing xsl template") } var f = this; var m = function (a) { f.tabClicked.call(f, a) }; var n = document.createElement("div"); var p = document.createElement("a"); p.appendChild(document.createTextNode("Source XML")); p.setAttribute("href", "javascript:void(0);"); p.onclick = m; var t = document.createElement("div"); t.appendChild(document.createTextNode(__sunboxXml.convertXmlToString(b))); t.style.display = "none"; n.appendChild(p); n.appendChild(t); this.container.appendChild(n); var s = document.createElement("div"); var u = document.createElement("a"); u.appendChild(document.createTextNode("Source XSL")); u.setAttribute("href", "javascript:void(0);"); u.onclick = m; var r = document.createElement("div"); r.appendChild(document.createTextNode(__sunboxXml.convertXmlToString(c))); r.style.display = "none"; s.appendChild(u); s.appendChild(r); this.container.appendChild(s); if (this.errors.length > 0) { var x = document.createElement("div"); var y = document.createElement("a"); y.appendChild(document.createTextNode("Errors")); y.setAttribute("href", "javascript:void(0);"); y.onclick = m; var A = document.createElement("div"); for (var z = 0; z < this.errors.length; z++) { var q = document.createElement("p"); q.style.color = "red"; q.appendChild(document.createTextNode(this.errors[z].errorTitle + ", " + this.errors[z].errorCode + ": ")); var v = __sunboxXml.parseHTML(this.errors[z].errorMessage).childNodes; for (var w = v.length; w > 0; w--) { q.appendChild(v[0]) } A.appendChild(q) } A.style.display = "none"; x.appendChild(y); x.appendChild(document.createTextNode("(" + this.errors.length + ")")); x.appendChild(A); this.container.appendChild(x) } } return this.xslTransform(b, c) }; o.prototype.renderDataSources = function (a) { var b = this.serializeDataSourcesToXml(a); this.wraper = document.createElement("div"); this.wraper.className = "sunbox-dataview-wrap"; var c = this.renderXml(b); if (c == null) return; this.notifyBeforeRender(this.container, c); if (typeof c == "string") { this.wraper.innerHTML = c } else { this.wraper.appendChild(c) } this.container.appendChild(this.wraper) }; o.prototype.xslTransform = function (a, b) { if (window.ActiveXObject) { return a.transformNode(b) } else if (document.implementation && document.implementation.createDocument) { var c = new XSLTProcessor(); c.importStylesheet(b); var d = c.transformToFragment(a, document); return d } return "XSL transformation failed: browser not supported." }; o.prototype.loadDataSources = function (b, c) { var d = b.length; var f = 0; for (var m = 0; m < b.length; m++) { if (b[m].Title.length == 0) continue; this.preprocessDataSource(b[m]); this.notifySourceLoadStart(b[m]); this.loadDataSource(b[m], "", function (a) { this.notifySourceLoadEnd(a); f++; if (f == d) c.call(this) }) } }; o.prototype.loadDataSource = function (b, c, d) { if (b.loading) return; var f = this; this.dataManager.loadDataSource(b, c, function (a) { d.call(f, a) }, function (a) { f.registerError(a.errorCode, a.errorMessage, "Error loading data from '" + b.Title + "'"); d.call(f, b) }) }; o.prototype.registerError = function (a, b, c) { if (typeof (this.errors) == "undefined") this.errors = []; this.errors.push({ errorCode: a, errorMessage: b, errorTitle: c }) }; o.prototype.preprocessDataSource = function (a) { var b = /\{(\w+)\[(.+?)\]\}/g; var c = b.exec(a.Query); while (c != null) { var d = c[1]; var f = c[2]; if (d.toString().toLowerCase() == "querystring") { a.Query = a.Query.replace(c[0], typeof (this.querySt[f]) == "undefined" ? "" : this.querySt[f]) } else if (d.toString().toLowerCase() == "params") { var m = this.getParameterValue(f); a.Query = a.Query.replace(c[0], m == null ? "" : m) } c = b.exec(a.Query) } }; o.prototype.serializeDataSourcesToXml = function (a) { var b = __sunboxXml.createDocument("", "response", null); var c = b.childNodes[0]; this.serializeBindings(c); for (var d = 0; d < a.length; d++) { if (a[d].Title.length == 0) continue; c.appendChild(a[d].rootElement) } return b }; o.prototype.getDataSourceById = function (a) { var b = this.options.datasources; for (var c = 0; c < b.length; c++) { if (b[c].Id == a) return b[c] } return null }; o.prototype.serializeBindings = function (a) { var b = a.ownerDocument; var c = b.createElement("__bindings"); var d = b.createElement("QueryStrings"); c.appendChild(d); __sunboxXml.appendObjectToXml(this.querySt, [], d); var f = b.createElement("Parameters"); for (var m = 0; m < this.options.parameters.length; m++) { var n = this.options.parameters[m]; var p = b.createElement(n.name); p.appendChild(b.createTextNode(n.value)); f.appendChild(p) } c.appendChild(f); a.appendChild(c); return a }; o.prototype.showLoader = function () { if (!this.options.showloader || this.options.loaderimage.length == 0) return; this.loaderImage = document.createElement("img"); this.loaderImage.setAttribute("src", this.options.loaderimage); this.loaderImage.setAttribute("alt", "loading..."); this.loaderImage.className = "sunboxdataview-loader"; this.container.appendChild(this.loaderImage) }; o.prototype.hideLoader = function () { if (typeof this.loaderImage == "undefined") return; this.container.removeChild(this.loaderImage) }; o.prototype.addParameter = function (a, b) { this.options.parameters.push({ name: a, value: b }) }; o.prototype.getParameterValue = function (a) { for (var b = 0; b < this.options.parameters.length; b++) { var c = this.options.parameters[b]; if (c.name.toLowerCase() == a.toLowerCase()) { return c.value } } return null }; o.prototype.queryString = function (a) { return this.queryStrings[a] }; o.prototype.initQueryStrings = function () { if (typeof (this.querySt) != 'undefined') return this.querySt; this.querySt = {}; var a = window.location.search.substring(1); var b = a.split("&"); for (var c = 0; c < b.length; c++) { var d = b[c].split("="); this.querySt[d[0].toLowerCase()] = d[1] } return this.querySt }; o.prototype.drawPagers = function () { var a = this.options.datasources; for (var b = 0; b < a.length; b++) { if (a[b].PagerStyle > 0 && a[b].PagerStyle < 3 && typeof (a[b].pagedData) != 'undefined' && a[b].pagedData != null) { var c; if (a[b].PagerContainerId.length > 0) { c = document.getElementById(a[b].PagerContainerId); if (c == null) c = this.container } else { c = this.container } var d = this.getDataSourcePagerHtml(a[b]); a[b].pagerWrap = d; c.appendChild(d) } } }; o.prototype.getDataSourcePagerHtml = function (c) { var d = document.createElement("div"); d.setAttribute("data-id", c.Id); d.className = "snbxdv-pager"; var f = document.createElement("a"); f.setAttribute("href", "javascript:void(0);"); var m = this; f.onclick = function () { var a = c.Id; var b = m.getDataSourceById(a); m.loadPagedData.call(m, b) }; f.className = "snbxdv-plink"; f.appendChild(document.createTextNode(c.PagerDisplayName.length == 0 ? "More..." : c.PagerDisplayName)); d.appendChild(f); return d }; o.prototype.loadPagedData = function (u) { if (u.Title.length == 0) return; var r = typeof (u.pagedData) != 'undefined' && u.pagedData != null ? u.pagedData : ""; if (r.length == 0) return; this.loadDataSource(u, r, function (a) { var b = this.serializeDataSourcesToXml(this.options.datasources); var c = this.renderXml(b); var d = this.wraper; var f; if (a.DynamicContentContainerId.length == 0) { f = c } else { var m = document.getElementById(a.DynamicContentContainerId); var n; if (typeof c == "string") { c = __sunboxXml.parseHTML(c) } n = this.findElementByIdInDocument(c, a.DynamicContentContainerId); if (m != null) d = m; f = n != null ? this.getHtmlOfXmlElement(n) : c } switch (a.PagerStyle) { case 1: d.innerHTML = f; break; case 2: case 3: var p = __sunboxXml.parseHTML(f).childNodes; for (var t = p.length; t > 0; t--) { d.appendChild(p[0]) } break } if (typeof (u.pagedData) == 'undefined' || u.pagedData == null) { if (typeof u.pagerWrap != "undefined") u.pagerWrap.style.display = "none" } this.notifyAfterRender(); if (typeof (window.FixRibbonAndWorkspaceDimensions) != "undefined") window.FixRibbonAndWorkspaceDimensions(); var s = this; setTimeout(function () { s.checkPagerLoadOnScroll.call(s) }, 10) }) }; o.prototype.findElementByIdInDocument = function (a, b) { if (a == null) return null; var c; if (a.attributes == null) c = null; else c = a.getAttribute("id"); if (c == null || b != c) { for (var d = 0; d < a.childNodes.length; d++) { var f = this.findElementByIdInDocument(a.childNodes[d], b); if (f != null) return f } return null } else { return a } }; o.prototype.getHtmlOfXmlElement = function (a) { if (typeof a.innerHTML != "undefined") return a.innerHTML; var b = ""; for (var c = 0; c < a.childNodes.length; c++) { b += a.childNodes[c].xml } return b }; o.prototype.getSourcesByPagerStyle = function (a) { var b = []; for (var c = 0; c < this.options.datasources.length; c++) { if (this.options.datasources[c].PagerStyle == a) { b.push(this.options.datasources[c]) } } return b }; o.prototype.checkPagerLoadOnScroll = function () { var a = this.windowContainer.scrollHeight - this.scrollingBeforePixels; var b = this.windowContainer.clientHeight; var c = this.windowContainer.scrollTop; if ((c + b) >= a) { var d = this.getSourcesByPagerStyle(3); for (var f = 0; f < d.length; f++) { this.loadPagedData(d[f]) } } }; o.prototype.getTarget = function (a) { var b = null; if (!a) a = window.event; if (a.target) b = a.target; else if (a.srcElement) b = a.srcElement; if (b.nodeType == 3) b = b.parentNode; return b }; o.prototype.afterRender = function (a) { this.events.push({ name: "afterRender", callback: a }) }; o.prototype.notifyAfterRender = function () { this.notifyEvent("afterRender") }; o.prototype.beforeRender = function (a) { this.events.push({ name: "beforeRender", callback: a }) }; o.prototype.notifyBeforeRender = function (a, b) { var c = { container: a, html: b }; this.notifyEvent("beforeRender", c) }; o.prototype.onSourceLoadStart = function (a) { this.events.push({ name: "sourceLoadStart", callback: a }) }; o.prototype.notifySourceLoadStart = function (a) { this.notifyEvent("sourceLoadStart", a) }; o.prototype.onSourceLoadEnd = function (a) { this.events.push({ name: "sourceLoadEnd", callback: a }) }; o.prototype.notifySourceLoadEnd = function (a) { this.notifyEvent("sourceLoadEnd", a) }; o.prototype.notifyEvent = function (a, b) { for (var c = 0; c < this.events.length; c++) { if (this.events[c].name == a) if (!this.events[c].callback(b)) break } }; return o })(); var MD5 = function (s) { function u(a, b) { return (a << b) | (a >>> (32 - b)) } function r(a, b) { var c, d, f, m, n; f = (a & 0x80000000); m = (b & 0x80000000); c = (a & 0x40000000); d = (b & 0x40000000); n = (a & 0x3FFFFFFF) + (b & 0x3FFFFFFF); if (c & d) { return (n ^ 0x80000000 ^ f ^ m) } if (c | d) { if (n & 0x40000000) { return (n ^ 0xC0000000 ^ f ^ m) } else { return (n ^ 0x40000000 ^ f ^ m) } } else { return (n ^ f ^ m) } } function x(a, b, c) { return (a & b) | ((~a) & c) } function y(a, b, c) { return (a & c) | (b & (~c)) } function A(a, b, c) { return (a ^ b ^ c) } function z(a, b, c) { return (b ^ (a | (~c))) } function q(a, b, c, d, f, m, n) { a = r(a, r(r(x(b, c, d), f), n)); return r(u(a, m), b) }; function v(a, b, c, d, f, m, n) { a = r(a, r(r(y(b, c, d), f), n)); return r(u(a, m), b) }; function w(a, b, c, d, f, m, n) { a = r(a, r(r(A(b, c, d), f), n)); return r(u(a, m), b) }; function o(a, b, c, d, f, m, n) { a = r(a, r(r(z(b, c, d), f), n)); return r(u(a, m), b) }; function W(a) { var b; var c = a.length; var d = c + 8; var f = (d - (d % 64)) / 64; var m = (f + 1) * 16; var n = Array(m - 1); var p = 0; var t = 0; while (t < c) { b = (t - (t % 4)) / 4; p = (t % 4) * 8; n[b] = (n[b] | (a.charCodeAt(t) << p)); t++ } b = (t - (t % 4)) / 4; p = (t % 4) * 8; n[b] = n[b] | (0x80 << p); n[m - 2] = c << 3; n[m - 1] = c >>> 29; return n }; function B(a) { var b = "", c = "", d, f; for (f = 0; f <= 3; f++) { d = (a >>> (f * 8)) & 255; c = "0" + d.toString(16); b = b + c.substr(c.length - 2, 2) } return b }; function X(a) { a = a.replace(/\r\n/g, "\n"); var b = ""; for (var c = 0; c < a.length; c++) { var d = a.charCodeAt(c); if (d < 128) { b += String.fromCharCode(d) } else if ((d > 127) && (d < 2048)) { b += String.fromCharCode((d >> 6) | 192); b += String.fromCharCode((d & 63) | 128) } else { b += String.fromCharCode((d >> 12) | 224); b += String.fromCharCode(((d >> 6) & 63) | 128); b += String.fromCharCode((d & 63) | 128) } } return b }; var l = Array(); var k, S, T, U, V, g, h, i, j; var C = 7, D = 12, E = 17, F = 22; var G = 5, H = 9, I = 14, J = 20; var K = 4, L = 11, M = 16, N = 23; var O = 6, P = 10, Q = 15, R = 21; s = X(s); l = W(s); g = 0x67452301; h = 0xEFCDAB89; i = 0x98BADCFE; j = 0x10325476; for (k = 0; k < l.length; k += 16) { S = g; T = h; U = i; V = j; g = q(g, h, i, j, l[k + 0], C, 0xD76AA478); j = q(j, g, h, i, l[k + 1], D, 0xE8C7B756); i = q(i, j, g, h, l[k + 2], E, 0x242070DB); h = q(h, i, j, g, l[k + 3], F, 0xC1BDCEEE); g = q(g, h, i, j, l[k + 4], C, 0xF57C0FAF); j = q(j, g, h, i, l[k + 5], D, 0x4787C62A); i = q(i, j, g, h, l[k + 6], E, 0xA8304613); h = q(h, i, j, g, l[k + 7], F, 0xFD469501); g = q(g, h, i, j, l[k + 8], C, 0x698098D8); j = q(j, g, h, i, l[k + 9], D, 0x8B44F7AF); i = q(i, j, g, h, l[k + 10], E, 0xFFFF5BB1); h = q(h, i, j, g, l[k + 11], F, 0x895CD7BE); g = q(g, h, i, j, l[k + 12], C, 0x6B901122); j = q(j, g, h, i, l[k + 13], D, 0xFD987193); i = q(i, j, g, h, l[k + 14], E, 0xA679438E); h = q(h, i, j, g, l[k + 15], F, 0x49B40821); g = v(g, h, i, j, l[k + 1], G, 0xF61E2562); j = v(j, g, h, i, l[k + 6], H, 0xC040B340); i = v(i, j, g, h, l[k + 11], I, 0x265E5A51); h = v(h, i, j, g, l[k + 0], J, 0xE9B6C7AA); g = v(g, h, i, j, l[k + 5], G, 0xD62F105D); j = v(j, g, h, i, l[k + 10], H, 0x2441453); i = v(i, j, g, h, l[k + 15], I, 0xD8A1E681); h = v(h, i, j, g, l[k + 4], J, 0xE7D3FBC8); g = v(g, h, i, j, l[k + 9], G, 0x21E1CDE6); j = v(j, g, h, i, l[k + 14], H, 0xC33707D6); i = v(i, j, g, h, l[k + 3], I, 0xF4D50D87); h = v(h, i, j, g, l[k + 8], J, 0x455A14ED); g = v(g, h, i, j, l[k + 13], G, 0xA9E3E905); j = v(j, g, h, i, l[k + 2], H, 0xFCEFA3F8); i = v(i, j, g, h, l[k + 7], I, 0x676F02D9); h = v(h, i, j, g, l[k + 12], J, 0x8D2A4C8A); g = w(g, h, i, j, l[k + 5], K, 0xFFFA3942); j = w(j, g, h, i, l[k + 8], L, 0x8771F681); i = w(i, j, g, h, l[k + 11], M, 0x6D9D6122); h = w(h, i, j, g, l[k + 14], N, 0xFDE5380C); g = w(g, h, i, j, l[k + 1], K, 0xA4BEEA44); j = w(j, g, h, i, l[k + 4], L, 0x4BDECFA9); i = w(i, j, g, h, l[k + 7], M, 0xF6BB4B60); h = w(h, i, j, g, l[k + 10], N, 0xBEBFBC70); g = w(g, h, i, j, l[k + 13], K, 0x289B7EC6); j = w(j, g, h, i, l[k + 0], L, 0xEAA127FA); i = w(i, j, g, h, l[k + 3], M, 0xD4EF3085); h = w(h, i, j, g, l[k + 6], N, 0x4881D05); g = w(g, h, i, j, l[k + 9], K, 0xD9D4D039); j = w(j, g, h, i, l[k + 12], L, 0xE6DB99E5); i = w(i, j, g, h, l[k + 15], M, 0x1FA27CF8); h = w(h, i, j, g, l[k + 2], N, 0xC4AC5665); g = o(g, h, i, j, l[k + 0], O, 0xF4292244); j = o(j, g, h, i, l[k + 7], P, 0x432AFF97); i = o(i, j, g, h, l[k + 14], Q, 0xAB9423A7); h = o(h, i, j, g, l[k + 5], R, 0xFC93A039); g = o(g, h, i, j, l[k + 12], O, 0x655B59C3); j = o(j, g, h, i, l[k + 3], P, 0x8F0CCC92); i = o(i, j, g, h, l[k + 10], Q, 0xFFEFF47D); h = o(h, i, j, g, l[k + 1], R, 0x85845DD1); g = o(g, h, i, j, l[k + 8], O, 0x6FA87E4F); j = o(j, g, h, i, l[k + 15], P, 0xFE2CE6E0); i = o(i, j, g, h, l[k + 6], Q, 0xA3014314); h = o(h, i, j, g, l[k + 13], R, 0x4E0811A1); g = o(g, h, i, j, l[k + 4], O, 0xF7537E82); j = o(j, g, h, i, l[k + 11], P, 0xBD3AF235); i = o(i, j, g, h, l[k + 2], Q, 0x2AD7D2BB); h = o(h, i, j, g, l[k + 9], R, 0xEB86D391); g = r(g, S); h = r(h, T); i = r(i, U); j = r(j, V) } var Y = B(g) + B(h) + B(i) + B(j); return Y.toLowerCase() };